# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=nginx-mod-headers-more
pkgver=0.35
pkgrel=1

_modname="${pkgname#nginx-mod-}"

pkgdesc="Nginx module to set and clear input and output headers"
arch=('loong64' 'x86_64')
depends=('nginx')
makedepends=('nginx-src')
url="https://github.com/openresty/headers-more-nginx-module"
license=('BSD')

source=(
  https://github.com/openresty/$_modname-nginx-module/archive/v$pkgver/$_modname-$pkgver.tar.gz
)
sha256sums=('1a216be253bbd5bf751d572ac2f93bdb61fbc2d78078d26c1335f4637cf2360a')

prepare() {
  mkdir -p build
  cd build
  ln -sf /usr/src/nginx/auto
  ln -sf /usr/src/nginx/src
}

build() {
  cd build
  /usr/src/nginx/configure \
    --with-compat \
    --add-dynamic-module=../$_modname-nginx-module-$pkgver
  make modules
}

package() {
  cd build/objs
  for mod in *.so; do
    install -Dm755 $mod "$pkgdir"/usr/lib/nginx/modules/$mod
  done

  install -Dm644 "$srcdir"/$_modname-nginx-module-$pkgver/README.markdown \
                 "$pkgdir"/usr/share/licenses/$pkgname/README.markdown
}
